<?php
/**
 # com_jvframwork - JV Framework
 # @version		1.5.x
 # ------------------------------------------------------------------------
 # author    Open Source Code Solutions Co
 # copyright Copyright (C) 2011 joomlavi.com. All Rights Reserved.
 # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL or later.
 # Websites: http://www.joomlavi.com
 # Technical Support:  http://www.joomlavi.com/my-tickets.html
-------------------------------------------------------------------------*/

// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

/**
 * Renders a position element
 *
 * @package 	Joomla.Framework
 * @subpackage		Parameter
 * @since		1.5
 */
 
class JElementMenuposition extends JElement
{
	/**
	* Element type
	*
	* @access	protected
	* @var		string
	*/
	var	$_name = 'Menuposition';

	function fetchElement($name, $value, &$node, $control_name)
	{
		$postion = $this->getMenuPosition();
        $input  = '';        
        
        if($node->attributes('onclick') && $node->attributes('text')){
            $input = '<button type="button" onclick="'.$node->attributes('onclick').'">'.JText::_($node->attributes('text')).'</button>';        
        } elseif($node->attributes('onclick')){
            $class.= 'onclick="'.$node->attributes('onclick').'"';
        }
        
        $option = JHTML::_('select.option', '', '-- Choose a menu to apply menu style --', 'id', 'title');
        array_unshift($postion, $option);
        
		return JHTML::_('select.genericlist',  $postion, ''.$control_name.'['.$name.'][]', 'multiple="multiple" size="10"', 'id', 'title', $value, $control_name.$name).$input;
	}
    
    /**
     * Get Main Menu Position
     *
     * @return array mainmenu position
     */     
    public function getMenuPosition(){
        $db =& JFactory::getDBO();
        $mainmenu = array();
                  
        $query = "SELECT * FROM #__modules WHERE module='mod_menu'";
        $db->setQuery($query);
        $resuft = $db->loadObjectList();
        
        return $resuft;         
    }
}
